public class ThreadDemo15 {
    private static long result = 0;
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(() ->{
//            long temp = 0;
            for (long i = 0; i <= 100_0000_0000L; i++) {
                result += i;
            }
//            result += temp;
        });
//        Thread t2 = new Thread(() ->{
//            long temp = 0;
//            for (long i = 50_0000_0001L; i < 100_0000_0000L; i++) {
//                temp += i;
//            }
//            result += temp;
//        });
        t.start();
//        t2.start();
        long beg = System.currentTimeMillis();
//        Thread.sleep(1000);
        t.join(); //什么时候t运行完，join就什么时候结束等待
//        t2.join();

        long end = System.currentTimeMillis(); //结束的时间
        System.out.println("result = " + result);
        System.out.println("time = " + (end - beg)+" ms");

    }
}
